#!/usr/bin/php
<?php
# Loading framework
include_once("setup.php");

# Setup logging
$logger = Log_Logger::get();
$logger->logToConsole(LOG_INFO);

$graph = new Rrd_Graph();
$graph->setParams($graphConf->get("param", array()));

$logger->info("Scheculed sensor check");
foreach($config->get("sensors", array()) as $name => $values) {
	$data = new Config_Dataset($values);
	$displayName = $data->get("name", $name);
	$logger->info("Updating database for: %s", $displayName);
	$sensor = $data->get("sensor");
	$db = new Rrd_Database($displayName, $name);
	if(($temp = $sensor->getTemp()) != null) {
		$db->update($temp);
	} else {
		$logger->error("Unable to read info from: %s", $displayName);
	}
	$graph->addDatabase($db);
}

$logger->info("Generating graphs");

$graph->createAll();

?>
